{{define "content"}}
<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="card">
            <div class="card-header">
                <h4 class="mb-0">
                    <i class="fas fa-{{if .Config.ID}}edit{{else}}plus{{end}} me-2"></i>
                    {{if .Config.ID}}编辑{{else}}新增{{end}}模型配置
                </h4>
            </div>
            <div class="card-body">
                <form method="POST" action="{{if .Config.ID}}/admin/update/{{.Config.ID}}{{else}}/admin/store{{end}}">
                    <div class="row mb-3">
                        <div class="col-md-6">
                            <label for="vendor_cn" class="form-label">供应商中文名 <span class="text-danger">*</span></label>
                            <input type="text" class="form-control" id="vendor_cn" name="vendor_cn" 
                                   value="{{.Config.VendorCN}}" required placeholder="如：OpenAI">
                        </div>
                        <div class="col-md-6">
                            <label for="vendor_en" class="form-label">供应商英文名 <span class="text-danger">*</span></label>
                            <input type="text" class="form-control" id="vendor_en" name="vendor_en" 
                                   value="{{.Config.VendorEN}}" required placeholder="如：openai">
                        </div>
                    </div>

                    <div class="row mb-3">
                        <div class="col-md-6">
                            <label for="model_name" class="form-label">模型名称</label>
                            <input type="text" class="form-control" id="model_name" name="model_name" 
                                   value="{{if .Config.ModelName}}{{.Config.ModelName}}{{end}}" placeholder="如：GPT-3.5-turbo">
                        </div>
                        <div class="col-md-6">
                            <label for="vendor_img" class="form-label">供应商图片路径</label>
                            <input type="text" class="form-control" id="vendor_img" name="vendor_img" 
                                   value="{{if .Config.VendorImg}}{{.Config.VendorImg}}{{end}}" placeholder="如：/images/openai-logo.png">
                        </div>
                    </div>

                    <div class="mb-3">
                        <label for="model_path" class="form-label">模型路径 <span class="text-danger">*</span></label>
                        <input type="text" class="form-control" id="model_path" name="model_path" 
                               value="{{.Config.ModelPath}}" required placeholder="如：http://localhost:8080/api/v1/chat">
                        <div class="form-text">模型的API地址或本地路径</div>
                    </div>

                    <div class="row mb-3">
                        <div class="col-md-6">
                            <label for="model_type" class="form-label">模型类型 <span class="text-danger">*</span></label>
                            <select class="form-select" id="model_type" name="model_type" required>
                                <option value="">请选择模型类型</option>
                                <option value="llm" {{if eq .Config.ModelType "llm"}}selected{{end}}>LLM (大语言模型)</option>
                                <option value="embedding" {{if eq .Config.ModelType "embedding"}}selected{{end}}>Embedding (嵌入模型)</option>
                                <option value="reranker" {{if eq .Config.ModelType "reranker"}}selected{{end}}>Reranker (重排序模型)</option>
                            </select>
                        </div>
                        <div class="col-md-6">
                            <label for="enabled" class="form-label">启用状态</label>
                            <select class="form-select" id="enabled" name="enabled">
                                <option value="1" {{if eq .Config.Enabled 1}}selected{{end}}>启用</option>
                                <option value="0" {{if eq .Config.Enabled 0}}selected{{end}}>禁用</option>
                            </select>
                        </div>
                    </div>

                    <div class="mb-3">
                        <label for="request_headers" class="form-label">请求头信息</label>
                        <textarea class="form-control" id="request_headers" name="request_headers" rows="4" 
                                  placeholder='如：{"Authorization": "Bearer token", "Content-Type": "application/json"}'>{{.Config.RequestHeaders}}</textarea>
                        <div class="form-text">JSON格式的请求头信息，可选</div>
                    </div>

                    <div class="d-flex justify-content-between">
                        <a href="/admin" class="btn btn-secondary">
                            <i class="fas fa-arrow-left me-1"></i>返回列表
                        </a>
                        <div>
                            <button type="reset" class="btn btn-outline-secondary me-2">重置</button>
                            <button type="submit" class="btn btn-primary">
                                <i class="fas fa-save me-1"></i>
                                {{if .Config.ID}}更新{{else}}创建{{end}}
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{{end}}
